//
//  LoginController.m
//  Happy to chat
//
//  Created by LL on 15/12/10.
//  Copyright © 2015年 LL. All rights reserved.
//

#import "LoginController.h"

@interface LoginController ()
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *password;
- (IBAction)loginAction:(id)sender;

@end

@implementation LoginController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


- (IBAction)loginAction:(id)sender {
    
    [AVUser logInWithUsernameInBackground:self.userName.text password:self.password.text block:^(AVUser *user, NSError *error) {
        if (user != nil) {
            
            UIStoryboard *sb = [UIStoryboard storyboardWithName:@"User" bundle:nil];
            
            UIViewController *user = [sb instantiateViewControllerWithIdentifier:@"user"];
            
            [self.navigationController pushViewController:user animated:YES];
            
        } else {
            
        }
    }];
    
}



- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
@end
